﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using sonic.Samples.Infrastructure.ViewModels;

namespace sonic.Samples.Infrastructure.Views
{
    public class View : UserControl, IView<IViewModelBase>
    {
        public View()
            : base()
        {
            // bind to is enabled
            Binding binding = new Binding();
            binding.Source = this.DataContext;
            binding.Path = new PropertyPath("IsEnabled");
            this.SetBinding(View.IsEnabledProperty, binding);
        }

        #region IView<IViewModelBase> Members

        public IViewModelBase Model
        {
            get { return this.DataContext as IViewModelBase; }
            set { this.DataContext = value; }
        }

        #endregion

        public object Header
        {
            get { return (object)GetValue(HeaderProperty); }
            set { SetValue(HeaderProperty, value); }
        }

        // Using a DependencyProperty as the backing store for Header.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty HeaderProperty =
            DependencyProperty.Register("Header", typeof(object), typeof(View), null);

    }
}
